var all = {
    "v": 'v1080',
    "userInfo":null, // 用户信息
    "menu": null, // menu
    "a_url": "http://v3-a.xgwl.net.cn", // a项目域名
    "app_url": "http://api.wabx.xgwl.net.cn/",// 测试接口
    //"app_url":"http://admin.api.ilovebaoxiao.com",  // 线上接口
    "sertype": 1, //sertype
    "sys": {
        "isMenuOpen": true,
        "unsetMnu": [
            '结算与订单'
        ]
    },
    "topHis": [],
    "beyond": [],
    "init":[],
}

var userinfo = JSON.parse(window.localStorage.getItem('r-ad-userinfo'))
userinfo ? all.userInfo = userinfo : all.userInfo = null

var menu = JSON.parse(window.localStorage.getItem('r-ad-menu'))
menu ? all.menu = menu : all.menu = null


//存用户信息
function setUserInfo(userInfo) {
    all.userInfo = userInfo
    window.localStorage.setItem('r-ad-userinfo', JSON.stringify(userInfo))
}
//修改token
function setToken(token){
all.userInfo = {} 
all.userInfo.token = token
}
//存menu
function setMenu(menu) {
all.menu = menu
window.localStorage.setItem('r-ad-menu', JSON.stringify(menu))
}
//接口信息
function setInit(init){
all.init = init
}

function setTopHis(val) {
all.topHis.push(val)
}

function setbeyond(val) {
all.beyond.push(val)
}

function cleHis() {
all.topHis = []
all.beyond = []
}
//取
function get(str) {
return all[str]
}

function init() {
var userinfo = JSON.parse(window.localStorage.getItem('r-ad-userinfo'))
if (userinfo) {
    all.userInfo = userinfo
}
}
//清空用户信息
function clear() {
all.userInfo = null
all.menu = null
}

function clearHis() {
all.topHis = []
}


module.exports = {
setUserInfo,
setMenu,
get,
init,
clear,
setTopHis,
clearHis,
setbeyond,
cleHis,
setToken,
setInit
}